Skip to content

Conversation

@sripraneeth
Copy link

@sripraneeth sripraneeth commented Nov 22, 2025

Updated System.Text.Json and System.Diagnostics.DiagnosticSource package references to version 10.0.0. Simplified the condition to check for TargetFramework not equal to net8.0.

When using Elastic.Clients.Elasticsearch 8.19.12 (NuGet) with System.Text.Json 10.0.0, a runtime MissingMethodException occurs:

System.MissingMethodException: Method not found:
'Boolean Elastic.Transport.Extensions.TransportSerializerExtensions.TryGetJsonSerializerOptions(...)'

Root Cause

The NuGet package Elastic.Transport 0.10.1 was compiled against System.Text.Json 8.0.5. When the application loads System.Text.Json 10.0.0 at runtime, there is a binary incompatibility due to internal breaking changes in
System.Text.Json (specifically in internal types like PooledByteBufferWriter).

The issue manifests during JSON serialization when Elastic.Transport calls JsonSerializer.SerializeAsync(), which internally uses types whose implementation changed between versions 8.x and 10.0.

Solution

Recompile Elastic.Transport and Elastic.Clients.Elasticsearch against System.Text.Json 10.0.0. This ensures the compiled IL references the correct internal type implementations.

Changes Made

elastic-transport-net (Elastic.Transport.csproj):

Key Takeaway

System.Text.Json 10.0.0 has internal breaking changes that require dependent libraries to be recompiled - simply updating the runtime DLL without recompiling causes MissingMethodException errors.

Updated System.Text.Json and System.Diagnostics.DiagnosticSource package references to version 10.0.0. Simplified the condition to check for TargetFramework not equal to net8.0.
@cla-checker-service
Copy link

cla-checker-service bot commented Nov 22, 2025

💚 CLA has been signed

@sripraneeth
Copy link
Author

When using Elastic.Clients.Elasticsearch 8.19.12 (NuGet) with System.Text.Json 10.0.0, a runtime MissingMethodException occurs:

System.MissingMethodException: Method not found:
'Boolean Elastic.Transport.Extensions.TransportSerializerExtensions.TryGetJsonSerializerOptions(...)'

Root Cause

The NuGet package Elastic.Transport 0.10.1 was compiled against System.Text.Json 8.0.5. When the application loads System.Text.Json 10.0.0 at runtime, there is a binary incompatibility due to internal breaking changes in
System.Text.Json (specifically in internal types like PooledByteBufferWriter).

The issue manifests during JSON serialization when Elastic.Transport calls JsonSerializer.SerializeAsync(), which internally uses types whose implementation changed between versions 8.x and 10.0.

Solution

Recompile Elastic.Transport and Elastic.Clients.Elasticsearch against System.Text.Json 10.0.0. This ensures the compiled IL references the correct internal type implementations.

Changes Made

elastic-transport-net (Elastic.Transport.csproj):

Key Takeaway

System.Text.Json 10.0.0 has internal breaking changes that require dependent libraries to be recompiled - simply updating the runtime DLL without recompiling causes MissingMethodException errors.

Copy link
Member

@flobernd flobernd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR.

Let's always use the STJ 10 package unless we are targeting net10 anyways.

<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
<ItemGroup Condition="'$(TargetFramework)' != 'net8.0'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<ItemGroup Condition="'$(TargetFramework)' != 'net8.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net10.0'">

@flobernd
Copy link
Member

flobernd commented Dec 3, 2025

@sripraneeth Hi. Are you planning to update the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants